<template>
    <el-tab-pane label="附件管理" name="attach">
        <z-table title="附件管理" url="/do/select/attachment" :params="params" :columns="attachColumns"
                 :size="5" :compact="150" @download="download">
            <template #header$="">
                <z-action label='添加附件' mode='dialog' :fields="attachFields" type='primary'
                          url='/api/attachment/addAttachment'/>
            </template>
            <template #action$="{ row }">
                <z-action label='下载' mode='confirm' cb='download' link :data="row"
                          url='/api/contract/download'/>
                <z-action label='删除' mode='confirm' link :data="row" url='/do/delete/attachment'/>
            </template>
        </z-table>
    </el-tab-pane>
</template>

<script>


export default {
    props: {
        params: Object,
    },
    data() {
        return {
            attachColumns: [
                {label: "附件名称", name: "title"},
                {label: "创建人", name: "creator"},
                {label: "创建时间", name: "createGmt"}
            ],
            attachFields: [
                {
                    label: "文件", name: "file", type: "attach", onChange: (val, formData) => {
                        formData.title = val.name;
                    },
                },
                {label: "附件名称", name: "title"},
                {
                    label: "管理人员",
                    name: "manager",
                    type: "user",
                    multiple: true,
                    tip: "创建人及合同负责人自动为管理员"
                },
                {label: "关联合同", name: "contractId", default: this.params.contractId, visible: true},
            ],
        }
    },
    methods: {
        download(params) {
            $.open(params)
        }
    }
}
</script>
